home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
comm
/
message.zip
/
MESSAGE.C
< prev
next >
Wrap
Text File
|
1992-05-08
|
34KB
|
849 lines
/*
╔════════════════════════════════════════════════════════════════════════════╗
║ MESSAGE MINDER ║
║ ║
║ By Brian Hill March, 1992 ║
║ ║
║ Message minder is a TSR program which will display a message ║
║ from the serial port on the screen. The message is cleared when the ║
║ user presses any key. The format for sending a messge is as follows: ║
║ 1) The com port on the sending machine should be set to 9600, N, 8, 1. ║
║ 2) A message is started with a SOH character. <alt> 1 will generate. ║
║ 3) A message is completed with a EOT character. <alt> 4 will generate. ║
║ ║
║ *NOTE when the user enters the un-install command: message u the program ║
║ will only un-install properly if it is the last TSR loaded. ║
║ ║
╚════════════════════════════════════════════════════════════════════════════╝
*/
#pragma check_stack( off ) // turn off stack checking
#pragma check_pointer( off ) // do not check for null pointers
#pragma pack(1) // byte align data to conserve memory
#include <string.h>
#include <stdlib.h>
#include < conio.h>
#include < stdio.h>
#include < bios.h>
#include < dos.h>
#define SOH 1 // start of header
#define EOT 4 // end of transmit
#define ESC 27 // ASCII value of escape key
#define ENTER 13 // ASCII value for enter key
#define BACKSPACE 8 // ASCII value for backspace key
#define NORM_VID 7 // normal video attribute
/*
╔════════════════════════════════════════════════════════════════════════════╗
║ Interrupt routines and function pointers ║
╚════════════════════════════════════════════════════════════════════════════╝
*/
void (interrupt _far *oldclock)(void); // old clock handler
void (interrupt _far *olddosok)(void); // old dosok handler
void (interrupt _far *oldkeybd)(void); // old keyboard handler
void interrupt _far keybd(void); // our keyboard handler
void interrupt _far clock(void); // our clock routine
void interrupt _far dosok(void); // our dosok handler
void interrupt _far serial(void); // Our serial port ISR
/*
╔════════════════════════════════════════════════════════════════════════════╗
║ Functions our program will call when active ║
╚════════════════════════════════════════════════════════════════════════════╝
*/
void memputs(char x,char y,char *string,char attrib); // display string
void save_screen(void); // save user's screen in screen[]
void restore_screen(void); // restore user's screen
void display_message(void); // display our message to screen
void draw_border(int type); // make a message border
void doit(void); // activate TSR
void memputs(char x, char y,char *string, char attrib);
void send_message(void); // Get message and transmit
void display_message(void); // show received message
void xmit_char(char ch); // sent a character out COM 1
int chk_xmit(void); // Is it OK to send a character?
int mem_gets(char *szStr,int xyStrRow, int xyStrCol); // get a string
void write_char(int x,int y,char ch,char attrib); // write char at x,y
void goto_xy(int x, int y); // move cursor
void get_xy(int *x, int *y); // get cursor pos -w- BIOS
void beep(void); // short "beep" thru PC's speaker
void main();
void init(void); // set up program
int check_install(int num); // check if program resident
void interrupt _far un_install (void); // pointer to un-install function
/*
╔════════════════════════════════════════════════════════════════════════════╗
║ Program data ║
╚════════════════════════════════════════════════════════════════════════════╝
*/
char buffer[81]; // our serial input buffer
char userscreen[481]; // save user's screen here
int port; // com1 port address
int _far *keyboard_status; // check if <ctrl> is pressed.
char _far *video = (char far *)0xB8000000; // pointer to color video memory
char _far *mode = (char far *)0x00400049; // pointer to CRT video mode
char _huge *tsrstack; // our stack space
char _huge *tsrbottom; // huge pointer to our PSP
char _huge *userstack; // user's stack space
char string[] = {"_MESSAGE"}; // TSR signature
struct tsrinfo
{
char *signature; // pointer to TSR signature
void (interrupt _far *un_install_ptr)(void); // pointer to un-install
} transient, _huge *resident;
/*
╔════════════════════════════════════════════════════════════════════════════╗
║ Flags ║
╚════════════════════════════════════════════════════════════════════════════╝
*/
char _far request_to_run; // Has message arrived?
char _far tsr_running; // Is menu displayed?
_segment(dosseg); // Segment of inDos flag.
char _based(dosseg) *indos; // Based pointer to InDos flag.
char video_mode_flag; // Waiting for appropriate video mode?
/*
╔════════════════════════════════════════════════════════════════════════════╗
║ Code ║
╚════════════════════════════════════════════════════════════════════════════╝
*/
void main(int argc, char **argv)
{
unsigned tsrsize; // memory needed for residence
int i; // a scratch pad variable
char ch;
/*
╔═════════════════════════════════════════════════════════════════════╗
║ Claculate program size ║
╚═════════════════════════════════════════════════════════════════════╝
*/
_asm mov WORD PTR tsrstack[0], sp // save our stack address
_asm mov WORD PTR tsrstack[2], ss
FP_SEG(tsrbottom) = _psp; // save PSP address
FP_OFF(tsrbottom) = 0;
tsrsize = ((tsrstack - tsrbottom) >> 4) + 1; // calculate program size
/*
╔═════════════════════════════════════════════════════════════════════╗
║ Is the program already installed? ║
╚═════════════════════════════════════════════════════════════════════╝
*/
transient.un_install_ptr = un_install; // establish pointer to un_install
transient.signature = (char *) string; //set pointer in structure to signatre
resident = (struct tsrinfo _huge *)&transient;// establish pointer to struct
if( (argc == 2) && (*argv[1] == 'u') ) // uninstall?
{
if(check_install(1))
printf("\n\nProgram Un-installed.");
else printf("\n\nProgram was not resident.");
exit(1);
}
else i